package action;

import controller.Action;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Curso;
import model.Professor;
import util.ConverteData;
import util.Estados;

public class EditarProfessorAction extends ManterProfessorAction {

    
    @Override
    public void setParametros(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try {
            
            int matriculaProfessor = Integer.parseInt(request.getParameter("matricula"));
            Professor professor = Professor.obterProfessor(matriculaProfessor);
            request.setAttribute("professor", professor);
            request.setAttribute("editar", "readonly");
            request.setAttribute("excluir", "");
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void efetuaPersistencia(Professor professor) throws ServletException {
        try {
            professor.editar();
        } catch (SQLException e) {
            throw new ServletException(e);
        } catch (ClassNotFoundException e) {
            throw new ServletException(e);
        }
    }

}
